package api.ttfullvideo;

import android.app.Activity;

import java.lang.ref.SoftReference;

public abstract class FullVideo_API_TT {

    public static String clazz = "com.dotools.toutiaolibrary.TT_FullVideo";

    private static SoftReference<FullVideo_API_TT> sf;

    public synchronized static FullVideo_API_TT getInstance() {

        if (sf == null || sf.get() == null) {
            Object o = null;
            try {
                o = Class.forName(clazz).newInstance();
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            } catch (InstantiationException e) {
                e.printStackTrace();
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            } catch (IllegalArgumentException e) {
                e.printStackTrace();
            }
            if (o != null) {
                sf = new SoftReference<>((FullVideo_API_TT) o);
                return (FullVideo_API_TT) o;
            }
        }
        return sf == null ? null : sf.get();
    }

    /**
     * @param context      Activity
     * @param appid        程序id
     * @param adposid      广告id
     * @param count        请求广告数量
     * @param isDebug      是否打开调试
     * @param orientation  视频的展示方向  1竖屏   2横屏
     * @param listener
     */
    public abstract void LoadTTFullVideo(Activity context, String appid, String adposid,  int count,int downloadMode, boolean isDebug, int orientation, final TTFullVideoListener listener);
    public abstract void  onDestroy();
    public interface TTFullVideoListener {
        /**
         * 广告的展示回调 每个广告仅回调一次
         */
        void onObShow();

        /**
         * 广告的下载bar点击回调
         */
        void onObVideoBarClick();

        /**
         * 广告关闭的回调
         */
        void onObClose();

        /**
         * 视频播放完毕的回调
         */
        void onVideoComplete();

        /**
         * 跳过视频播放
         */
        void onSkippedVideo();

        void onError(int code, String message);

    }
}